package parseAndHandleTool;

import com.oocl.crm_system.Customer;
import com.oocl.crm_system.DoublyList;


public class HandleCmd {
	private ParseCmd parseCmdTool = new ParseCmd();
	
	public void handle(DoublyList<Customer> list,String inputByConsole){
		String input = inputByConsole;
		switch(inputByConsole.charAt(0)){
		case 'A':
			parseCmdTool = new ParseCmdForAdd();
			((ParseCmdForAdd)parseCmdTool).parseCmdForAdd(list,input);
			break;
		case 'D':
			parseCmdTool = new ParseCmdForDelete();
			((ParseCmdForDelete)parseCmdTool).parseCmdForDelete(list,input);
			break;
		case 'U':
			parseCmdTool = new ParseCmdForUpdate();
			((ParseCmdForUpdate)parseCmdTool).parseCmdForUpdate(list,input);
			break;
		case 'O':
			parseCmdTool = new ParseCmdForSort();
			((ParseCmdForSort)parseCmdTool).parseCmdForSort(list,input);
			break;
		case 'H':
			parseCmdTool = new ParseCmdForHelp();
			((ParseCmdForHelp)parseCmdTool).parseCmdForHelp(list,input);
			break;
		case 'L':
			parseCmdTool = new ParseCmdForLook();
			((ParseCmdForLook)parseCmdTool).parseCmdForLook(list,input);
			break;
		default:
			System.out.println("it is a wrong command,please enter a correct command.");
			break;
		}
	}
}
